﻿using System;
using System.Collections.Generic;
using System.Threading;
using System.Windows.Forms;
using csvm.coordinator.contract;
using csvm.datamodel.contract;

namespace csvm.portal.testexe
{
  class CoordinatorMock : ICoordinator
  {
    public IEnumerable<Page> LoadPages(string filename, out Record header)
    {
      MessageBox.Show(filename);

      header = new Record(new[] { "col_0", "col_1", "col_2" });

      var lineCounter = 0;
      var pages = new List<Page>();
      for (var i = 0; i < 5; ++i)
      {
        var records = new List<Record>();
        for (var j = 0; j < 20; ++j)
        {
          var record = new Record(new[]
                                    {
                                      lineCounter + "_0",
                                      lineCounter + "_1",
                                      lineCounter + "_2",
                                    });
          records.Add(record);
          lineCounter++;
        }
        pages.Add(new Page(records));
      }

      for (var i = 0; i < 101; ++i)
      {
        Thread.Sleep(10);
        OnProgressChanged(i);
      }

      return pages;
    }

    public event Action<double> OnProgressChanged;
  }
}
